package itrans; 

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;

public class DBUtil {

  // Database constants
  public static final String DB_JDBC_DRIVER = "com.mysql.jdbc.Driver";
  public static final String DB_URL = "jdbc:mysql://mathlab.utsc.utoronto.ca:3306/cscc09f12_13";
  public static final String DB_USER = "cscc09f12_13";
  public static final String DB_PWD = "tsukihime";

  // Returns a connection object
  public synchronized static Connection getConnection() throws ClassNotFoundException,
      SQLException {
    try {
	Class.forName(DB_JDBC_DRIVER);
        return DriverManager.getConnection(DB_URL, DB_USER, DB_PWD);
    }
    catch(SQLException ex) {
        System.err.println("SQLException: " + ex.getMessage());
	return null;
    }
    catch (Exception e) {
      	e.printStackTrace();
	return null;
    }
  }
}
